import datetime
from models.base import *


class EnterpriseAccount(TimestampMixin, OtherMixin, TenantMixin, UidMixin, Model):
    account_id = fields.CharField(max_length=32, index=True, description="account_id")
    enterprise_id = fields.CharField(max_length=32, index=True, description="enterprise_id")
    state = fields.IntField(description="1 default", default=0)
    activate = fields.IntField(description="activate 1", default=0)

    class Meta:
        abstract = False
        table = 'a_enterprise_account'
        table_description = '企业用户表'

    async def list_to_dict(self):
        request_dict = {f: getattr(self, f) for f in self._meta.fields}
        request_dict['create_ts'] = datetime.datetime.strftime(request_dict['create_ts'], '%Y-%m-%d')
        request_dict['update_ts'] = datetime.datetime.strftime(request_dict['update_ts'], '%Y-%m-%d')
        return request_dict
